package cn.zcy.utils;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * 代码执行效率的切面
 */
@Component
//@Aspect
//@Order(0)
public class TimeUtils {
    private Long time;

    @Before("execution(public * cn.zcy.service.impl.*.*(..))")
    public void before() {
        time = System.currentTimeMillis();
        System.out.println("开始时间=" + time);
    }

    @After("execution(public * cn.zcy.service.impl.*.*(..))")
    public void after() {
            System.out.println("结束时间=" + (System.currentTimeMillis() - time)/1000);
    }

}
